#coding:utf-8
'''
Created on 2016年10月9日

@author: liuguoqiang
'''
import pymysql

class SqlManager(object):
    def get_uids(self):
         db = pymysql.connect('127.0.0.1','root','root','WeiboAD')
         cursor = db.cursor()
         sql = 'select distinct uid from weiboInfo'
         cursor.execute("SET NAMES 'utf8';")
         cursor.execute(sql)
         results = cursor.fetchall()
         records=[]
         for result in list(results):            
             records.append(result[0]);
         print records
         return records;
    
    
    def get_weibos(self, uid):
         db = pymysql.connect('127.0.0.1','root','root','WeiboAD')
         cursor = db.cursor()
         sql = 'select * from weiboInfo where uid ='+uid
         cursor.execute("SET NAMES 'utf8';")
         cursor.execute(sql)
         results = cursor.fetchall()
         records=[]
         text = ''
         for result in list(results):
             dic={}
             dic['idstr']=result[0]
             dic['id']=result[1]
             dic['weibo']=result[8]
             records.append(dic);
             text = text + result[8]
         return text
         